package cn.springcloud.fix.uaa.web.config.adapter;

import cn.springcloud.fix.uaa.web.provider.MobileAuthenticationProvider;
import cn.springcloud.fix.uaa.web.service.IUserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.DefaultSecurityFilterChain;
import org.springframework.stereotype.Component;

/**
 * mobile的相关处理配置
 */
@Component
public class MobileSecurityConfigurerAdapter extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {

    @Autowired
    private PasswordEncoder passwordEncoder;

    @Autowired
    private IUserDetailsService userDetailsService;

    @Override
    public void configure(HttpSecurity http) {
        MobileAuthenticationProvider provider = new MobileAuthenticationProvider(userDetailsService, passwordEncoder);
        http.authenticationProvider(provider);
    }
}
